package http;

import java.io.IOException;
import java.net.URL;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.osgi.service.http.HttpContext;

public class LibraryContext implements HttpContext {

	// --- Implementation HttpContext interface --------------------------------

	public String getMimeType(String resource) {
		if (resource.endsWith(".jpg")) {
			return "image/jpeg";
		}
		return null;
	}
	

	public URL getResource(String resource) {
		System.out.println("Get resource: " + resource);
		URL resourceURL = getClass().getResource(resource);
		System.out.println("return URL: " + resourceURL);
		return resourceURL;
	}

	public boolean handleSecurity(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		return true;
	}

}
